package com.springboot.service.impl;

import com.springboot.dto.Doctor;
import com.springboot.mapper.DoctorFieldFormMapper;
import com.springboot.mapper.DoctorInfoFormMapper;
import com.springboot.model.DoctorInfoForm;
import com.springboot.service.PatientIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.nio.channels.ScatteringByteChannel;
import java.util.ArrayList;
@Service
public class PatientIndexServiceImpl implements PatientIndexService {
    @Autowired
    DoctorInfoFormMapper doctorInfoFormMapper;

    @Autowired
    DoctorFieldFormMapper doctorFieldFormMapper;

    /**
     * 此时并未考虑显示科室，只显示医生职称
     * @param doctorRank
     * @return
     */
    @Override
    public ArrayList<Doctor> showMainDoctors(String doctorRank) {
       ArrayList<Doctor> doctors = new ArrayList<>();
       ArrayList<DoctorInfoForm> doctorInfoForms = new ArrayList<>();
       try {
           doctorInfoForms = doctorInfoFormMapper.selectIncludeByRank(doctorRank);
           for(int i=0;i<doctorInfoForms.size();i++)
           {
               DoctorInfoForm doctorInfoForm = doctorInfoForms.get(i);
               System.out.println(doctorInfoForm.toTestString());
               Doctor doctor = new Doctor();
               doctor.setDoctorInfoForm(doctorInfoForm);
               doctors.add(doctor);
           }
           return doctors;
       }
       catch (Exception e)
       {
           System.out.println("查询为空");
       }
       return doctors;
    }
}
